

public class Vector implements Structura {
	protected int[] vector;
	private static int i;
	private static int max;
	
	
	public Vector()
	{
		i=0;
		max=10;
		vector=new int[10];
	}
	
	
	public Vector(int dimensiune)
	{
		i=0;
		max=dimensiune;
		vector=new int[dimensiune];
	}
	
	
	private int[] getVector()
	{
		return this.vector;
	}
	
	
	private void setVector(int[] v)
	{
	int n=v.length;
	   for(int i=0;i<n;i++)
	   {
	   	this.vector[i]=v[i];
	   }
	    
}
	
	
	public void adauga(int elem)
	{
		if(i<max)
		{
		vector[i]=elem;
		i=i+1;
		}
		else
		{
			System.out.println("Vectorul este plin, nu se poate adauga elementul "+elem);
		}
	}

	
	public void sterge(int elem)
	{
	int i=0;
	int[] aux=new int[max];
	int iAux=0;
	int nrAparitii=0;
	while(i<i)	{
		if (this.vector[i]!=elem)
		{
		  	aux[iAux]=this.vector[i];
		  	iAux++;
		}
		else
		{
			nrAparitii++;
		}
		i++;
	}
	this.setVector(aux);
	i=i-nrAparitii;
}
	
	
	
	public int elementLaIndice(int indice)
	{
	if((indice>=0)&&(indice<max)&&(indice<=i))
	{
		return this.vector[indice];
	}
    else	    {
		 System.out.println("[Eroare] Indicele "+indice+" este invalid.");
		 return -1;
   }
}
	
	
	public void afiseaza()
	{
	if(i>0)
	{
	for(int i=0;i<i;i++)
	{
		System.out.println("vector["+i+"]="+this.vector[i]);
	}
	}
	else
	{
		System.out.println("Vectorul este vid");
	}	
	}

}
